import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:share_fit/app/components/back_btn_icon.dart';
import 'package:share_fit/app/helper/ext/tr_ext.dart';
import 'package:share_fit/app/tools/color_const.dart';
import 'package:share_fit/generated/locales.g.dart';

import 'pressure_logic.dart';

class PressurePage extends StatelessWidget {
  PressurePage({super.key});

  final logic = Get.put(PressureLogic());
  final state = Get.find<PressureLogic>().state;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        leading: BackBtnIcon(onTap: () => Get.back()),
        centerTitle: true,
        title: Text(LocaleKeys.settings_pressure.ts, style: TextStyle(fontSize: 54.sp)),
      ),
      body: Container(
        padding: EdgeInsets.symmetric(horizontal: 40.w),
        child: ListView(
          children: [
            SizedBox(height: 90.h),
            Container(
              height: 175.h,
              padding: EdgeInsets.only(left: 70.w, right: 20.w),
              decoration: BoxDecoration(color: Colors.white70, borderRadius: BorderRadius.circular(60.r)),
              child: Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [Text(LocaleKeys.settings_pressure_switch.ts), Transform.scale(
                  scale: 0.7,
                  child: GetBuilder<PressureLogic>(
                    id: 'pressure_switch',
                    builder: (_) => CupertinoSwitch(
                      value: state.pressureEnable,
                      activeColor: ColorConst.accentColor,
                      onChanged: (value) {
                        logic.setPressureEnable(value);
                      },
                    ),
                  ),
                ),],
              ),
            ),
            Container(
              padding: EdgeInsets.only(left: 102.w, top: 39.h),
              child: Text(LocaleKeys.settings_pressure_tips.ts,
                  style: TextStyle(
                      fontSize: 42.sp, color: ColorConst.primaryFontColor)),
            ),
          ],
        ),
      ),
    );
  }
}
